<!DOCTYPE HTML PUBLIC "-//ORA//DTD CD HTML 3.2//EN">
<HTML>
<HEAD>
<TITLE>[Chapter 1] 1.2 New Language Features in Java 1.1</TITLE>
<META NAME="author" CONTENT="Mark Grand">
<META NAME="date" CONTENT="Thu Jul 31 13:05:16 1997">
<META NAME="form" CONTENT="html">
<META NAME="metadata" CONTENT="dublincore.0.1">
<META NAME="objecttype" CONTENT="book part">
<META NAME="otheragent" CONTENT="gmat dbtohtml">
<META NAME="publisher" CONTENT="O'Reilly &amp; Associates, Inc.">
<META NAME="source" CONTENT="SGML">
<META NAME="subject" CONTENT="java">
<META NAME="title" CONTENT="Java Language Reference">
<META HTTP-EQUIV="Content-Script-Type" CONTENT="text/javascript">
</HEAD>
<body vlink="#551a8b" alink="#ff0000" text="#000000" bgcolor="#FFFFFF" link="#0000ee">

<DIV CLASS=htmlnav>
<H1><a href='index.htm'><IMG SRC="gifs/smbanner.gif"
     ALT="Java Language Reference" border=0></a></H1>
<table width=515 border=0 cellpadding=0 cellspacing=0>
<tr>
<td width=172 align=left valign=top><A HREF="ch01_01.htm"><IMG SRC="gifs/txtpreva.gif" ALT="Previous" border=0></A></td>
<td width=171 align=center valign=top><B><FONT FACE="ARIEL,HELVETICA,HELV,SANSERIF" SIZE="-1">Chapter 1<br>Introduction</FONT></B></TD>
<td width=172 align=right valign=top><A HREF="ch01_03.htm"><IMG SRC="gifs/txtnexta.gif" ALT="Next" border=0></A></td>
</tr>
</table>

&nbsp;
<hr align=left width=515>
</DIV>
<DIV CLASS=sect1>
<h2 CLASS=sect1><A CLASS="TITLE" NAME="JLR2-CH-1-SECT-2">1.2 New Language Features in Java 1.1</A></h2>

<P CLASS=para>
Although Java 1.1 is a massive new release, there are relatively few
changes to the Java language in this version. The new features of the
language are quite significant, however, as they add useful
functionality and make the Java language even more elegant. Here is a
brief summary of the new features of the Java language in Java 1.1:

<P>
<UL CLASS=itemizedlist>
<li CLASS=listitem>The addition of inner classes is the largest change to the Java
language in Java 1.1. With this new feature, classes can be defined as
members of other classes, just like variables and methods. Classes can
also be defined within blocks of Java code, just like local variables.
A class that is declared inside of another class may have access to
the instance variables of the enclosing class; a class declared within
a block may have access to the local variables and/or formal parameters
of that block.

<P CLASS=para>
Inner classes include: nested top-level classes and interfaces, 
member classes, local classes, and anonymous classes.
The various types of inner clases are described
in <A HREF="ch05_03.htm#JLR2-CH-5-SECT-3.7">Inner Classes</A>. The syntax for
nested top-level and member classes is covered 
in <A HREF="ch05_04.htm#JLR2-CH-5-SECT-4.4.6">Nested Top-Level and Member Classes</A>, while the
syntax for nested top-level interfaces is covered
in <A HREF="ch05_05.htm#JLR2-CH-5-SECT-5.4.3">Nested Top-Level Interfaces</A>.
The syntax for local classes is described 
in <A HREF="ch06_01.htm#JLR2-CH-6-SECT-1.2">Local Classes</A>.
The syntax for an anonymous class is part of an allocation
expression, as covered 
in <A HREF="ch04_02.htm#JLR2-CH-4-SECT-2">Allocation Expressions</A>.

<P>
<li CLASS=listitem>Java 1.1 provides the ability to declare <tt CLASS=literal>final</tt>
local variables, method parameters, and <tt CLASS=literal>catch</tt>
clause parameters. <tt CLASS=literal>final</tt> local variables, method
parameters, and <tt CLASS=literal>catch</tt> parameters are needed to
allow local classes to access these entities within the scope of their
blocks.  The syntax for <tt CLASS=literal>final</tt> local variables is
described in <A HREF="ch06_01.htm#JLR2-CH-6-SECT-1.1">Local Variables</A>, while
<tt CLASS=literal>final</tt> method parameters are covered 
in <A HREF="ch05_04.htm#JLR2-CH-5-SECT-4.4.2.4">Method formal parameters</A>. The new syntax 
for the <tt CLASS=literal>catch</tt> clause is described 
in <A HREF="ch06_12.htm#JLR2-CH-6-SECT-12">The try Statement</A>.

<P>
<li CLASS=listitem>Instance initializers are blocks of code that execute when an
instance of a class is created. Instance initializers have been added
in Java 1.1 to allow anonymous classes to perform any necessary
initialization, since anonymous classes can not define any
constructors. The syntax for instance initializers is covered 
in <A HREF="ch05_04.htm#JLR2-CH-5-SECT-4.4.5">Instance Initializers</A>.

<P>
<li CLASS=listitem>As of Java 1.1, <tt CLASS=literal>final</tt> variable declarations 
do not have to include initializers. A <tt CLASS=literal>final</tt>
variable declaration that does not include an initializer is
called a blank final. The functionality of blank finals is
described in <A HREF="ch05_04.htm#JLR2-CH-5-SECT-4.4.1.1">Variable modifiers</A>
and <A HREF="ch06_01.htm#JLR2-CH-6-SECT-1.1.1">Final local variables</A>.

<P>
<li CLASS=listitem>A class literal is a new kind of primary expression that can be
used to obtain a <tt CLASS=literal>Class</tt> object for a particular
data type. Class literals have been added to support the new
Reflection API in Java 1.1. The syntax for class literals is
covered in <A HREF="ch04_01.htm#JLR2-CH-4-SECT-1.9">Class Literals</A>.

<P>
<li CLASS=listitem>An anonymous array is an array created and initialized without
using a variable initializer. The syntax for an anonymous array 
is part of an allocation expression, as described 
in <A HREF="ch04_02.htm#JLR2-CH-4-SECT-2">Allocation Expressions</A>. 

<P>
</UL>
</DIV>


<DIV CLASS=htmlnav>

<P>
<HR align=left width=515>
<table width=515 border=0 cellpadding=0 cellspacing=0>
<tr>
<td width=172 align=left valign=top><A HREF="ch01_01.htm"><IMG SRC="gifs/txtpreva.gif" ALT="Previous" border=0></A></td>
<td width=171 align=center valign=top><a href="index.htm"><img src='gifs/txthome.gif' border=0 alt='Home'></a></td>
<td width=172 align=right valign=top><A HREF="ch01_03.htm"><IMG SRC="gifs/txtnexta.gif" ALT="Next" border=0></A></td>
</tr>
<tr>
<td width=172 align=left valign=top>A "Hello World" Program</td>
<td width=171 align=center valign=top><a href="index/idx_0.htm"><img src='gifs/index.gif' alt='Book Index' border=0></a></td>
<td width=172 align=right valign=top>Compiling a Java Source File</td>
</tr>
</table>
<hr align=left width=515>

<IMG SRC="gifs/smnavbar.gif" USEMAP="#map" BORDER=0> 
<MAP NAME="map"> 
<AREA SHAPE=RECT COORDS="0,0,108,15" HREF="../javanut/index.htm"
alt="Java in a Nutshell"> 
<AREA SHAPE=RECT COORDS="109,0,200,15" HREF="../langref/index.htm" 
alt="Java Language Reference"> 
<AREA SHAPE=RECT COORDS="203,0,290,15" HREF="../awt/index.htm" 
alt="Java AWT"> 
<AREA SHAPE=RECT COORDS="291,0,419,15" HREF="../fclass/index.htm" 
alt="Java Fundamental Classes"> 
<AREA SHAPE=RECT COORDS="421,0,514,15" HREF="../exp/index.htm" 
alt="Exploring Java"> 
</MAP>
</DIV>

</BODY>
</HTML>
